/** 
 * CommandFrame.java
 * @author Lex
 * 2007-8-17 ����12:37:27
 */
package fun.ui.frames;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;

import org.lex.swing.widgets.OutputStreamTextArea;

import fun.ui.FunMainFrame;

public class TextAreaFrame extends BasicInternalFrame {
	private JPanel pane = null;
	private JScrollPane scrollPane = null;
	private OutputStreamTextArea textArea = null;

	public TextAreaFrame(FunMainFrame mainframe) {
		super(mainframe);
		initialize();
	}

	public TextAreaFrame appene(Object o) {
		this.getTextArea().append(String.valueOf(o));
		return this;
	}

	public OutputStreamTextArea getTextArea() {
		if (textArea == null) {
			textArea = new OutputStreamTextArea();
			textArea.setBorder(new EmptyBorder(5, 6, 5, 5));
			textArea.setTabSize(4);
		}
		return textArea;
	}

	protected JPanel getPane() {
		if (pane == null) {
			pane = new JPanel();
			pane.setLayout(new BorderLayout());
			pane.add(getScrollPane(), BorderLayout.CENTER);
		}
		return pane;
	}

	private void initialize() {
		this.setContentPane(getPane());
	}

	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setViewportView(getTextArea());
		}
		return scrollPane;
	}
}
